#/bin/sh

if [ $# -lt 1 ]
then
echo "Usage: $0 <pack_name> [--dev]"
exit 1
fi

ROOT='/usr/local/bin'
NAME=`[ -z "$1" ] && echo "" || echo "$1"`
DEV=`[ -z "$2" ] && echo "--save" || echo "--save-dev"`

PROFILE_NAME=".bash_profile"
PROFILE_PATH="${HOME}/${PROFILE_NAME}"
touch $PROFILE_PATH

echo "sourcing..."
source ${PROFILE_PATH}

#! use the project node version
nvm use

npm install ${NAME} ${DEV}

if [ "--save" = "$DEV" ]
then
npm-shrinkwrap
shrinkpack
fi
